<?php
defined('IN_PHPCMS') or exit('No permission resources.');
define('CACHE_MODEL_PATH',PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
pc_base::load_app_class('admin','admin',0);
pc_base::load_sys_class('form','',0);
class xiaoshuo extends admin{
	private $db, $m_db, $M;
	function __construct() {
		$this->db = pc_base::load_model('sitemodel_model');
		$this->m_db = pc_base::load_model('sitemodel_field_model');
		$this->module_db = pc_base::load_model('module_model');
		$this->M = new_html_special_chars(getcache('xiaoshuo', 'commons'));
		$this->siteid = intval($_GET[siteid]) ? intval($_GET[siteid]) : get_siteid();
		$this->M = $this->M[$this->siteid];
	}
	public function init() {
		$siteid = $this->siteid;
		if(isset($_POST['dosubmit'])) {
			//合并数据库缓存与新提交缓存
			$r = $this->module_db->get_one(array('module'=>'xiaoshuo'));
			$search_setting = string2array($r['setting']);
			
			$search_setting[$siteid] = $_POST['setting'];
			$setting = array2string($search_setting);
			setcache('xiaoshuo', $search_setting);
			$this->module_db->update(array('setting'=>$setting),array('module'=>'xiaoshuo'));
			showmessage(L('operation_success'),HTTP_REFERER);
		} else {
			$r = $this->module_db->get_one(array('module'=>'xiaoshuo'));
			$setting = string2array($r['setting']);
			if($setting[$siteid]){
				extract($setting[$siteid]);
			}
			include $this->admin_tpl('setting');
		}
	}
}
?>